package cn.uce.cc.rest.control;

import cn.uce.base.entity.CsCustomerInformation;
import cn.uce.base.vo.CsCustomerInformationVo;
import cn.uce.cc.api.service.biz.ICcCustomerInformationBiz;
import cn.uce.cc.api.service.biz.ICcosWaybillBiz;
import cn.uce.cc.srv.utils.ScreenBusiAbnPubApiConver;
import cn.uce.utils.StringUtil;
import cn.uce.web.common.base.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("cs/CsCustomerInfomation")
public class CsCustomerInformationController  extends BaseController {
    @Resource
    ICcCustomerInformationBiz ccCustomerInformationBiz;

    @RequestMapping(value = "/getCustomerInformationQueryPhone")
    @ResponseBody
    public Map<String,Object> getCustomerInformationQueryPhone(String phone) {
        //对手机号进行非空校验，如果是空值，直接返回空数据
        if (StringUtil.isNotEmpty(phone)){
            CsCustomerInformationVo csCustomerInformationVo = ccCustomerInformationBiz.getCustomerInformationQueryPhone(phone);
            return this.returnSuccess(csCustomerInformationVo);
        }else{
            return this.returnSuccess(new CsCustomerInformationVo());
        }
    }


    @RequestMapping(value = "/saveByPhone.do")
    @ResponseBody
    public Map<String,Object> saveByPhone(CsCustomerInformation entity) {
        //对手机号进行非空校验，如果是空值，直接返回空数据
        if(entity == null || StringUtil.isEmpty(entity.getPhone())){
            return returnSuccess(-1);
        }
        return returnSuccess(ccCustomerInformationBiz.saveByPhone(entity));
    }
}
